//
//  GuideViewCtrl.m
//  DogeLegs
//
//  Created by 宋华 on 2017/8/16.
//  Copyright © 2017年 宋华. All rights reserved.
//

#import "GuideViewCtrl.h"
#import "AppDelegate.h"

@interface GuideViewCtrl ()

@property (weak, nonatomic) IBOutlet UIImageView *guideImageview;

@property (weak, nonatomic) IBOutlet UILabel *versioLabel;

@end

@implementation GuideViewCtrl

- (void)viewDidLoad {
    [super viewDidLoad];
    [NSNotificationCenter addGetUserConfigDoneNotification:self action:@selector(reloadImageview:)];
    [self layoutImageview];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidAppear:(BOOL)animated {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        // Remove self
        [self gotoMainOrLoginCtrl];
    });
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark -通知事件
- (void)reloadImageview:(NSNotification *)notif {
    [self layoutImageview];
}

#pragma mark -imageview加载
- (void)layoutImageview {
    //流程是这样的，加载本地的url，等去获取到配置接口里的url再刷新imageview
    [self.guideImageview sd_setImageWithURL:[NSURL URLWithString:[UserConfigManager shareInstance].guideUrl] placeholderImage:[UIImage imageNamed:@"IOS7501334px01.png"]];
}

#pragma mark -gotoMainCtrl
- (void)gotoMainOrLoginCtrl {
    AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
    [delegate goToMainOrLoginController];
}

@end
